<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    <div class="container-div">
		<form id="baseInfo-form">
			<div class="select-list">
				<ul>
					<li>
						项目经理：<input type="text" name="projectId"/>
					</li>
					<li>
						项目状态：<input type="text" name="projectStatus"/>
					</li>
					<li>
						上周考勤计算：<input type="date" id="cal-date" name="cal-date"/>
					</li>
					<li>
						<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>搜索</a>
						<a class="btn btn-primary btn-rounded btn-sm" onclick="exportExcel()"><i class="fa fa-address-card"></i>导出Excel</a>
					</li>
				</ul>
			</div>
		</form>

		<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
			<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="pm:projectInfo:add">
				<i class="fa fa-plus"></i> 添加
			</a>
			<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="pm:projectInfo:edit">
	            <i class="fa fa-edit"></i> 修改
	        </a>
			<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="pm:projectInfo:remove">
				<i class="fa fa-remove"></i> 删除
			</a>

			<a class="btn btn-primary btn-edit disabled" onclick="projectBudgetInfo()" >
				<i class="fa fa-edit"></i> 项目预算
			</a>

			<a class="btn btn-primary btn-edit disabled" onclick="projectProcurementResourceInfo()" >
				<i class="fa fa-edit"></i> 采购资源
			</a>

			<a class="btn btn-primary btn-edit disabled" onclick="projectCompanyProcurementInfo()" >
				<i class="fa fa-edit"></i> 公司采购
			</a>
		</div>
			
		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table" data-mobile-responsive="true"></table>
		</div>
    </div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('pm:projectInfo:edit')}]];
        var removeFlag = [[${@permission.hasPermi('pm:projectInfo:remove')}]];
        var prefix = ctx + "pm/projectInfo";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                modalName: "项目信息",
				search: false,
				showSearch: false,
				showColumns: false,
				showToggle: false,
				showExport: false,
				showRefresh: false,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'id', 
					title : '序号主键' 
				},
				{
					field : 'taskOrderTime', 
					title : '任务书下达时间',
					formatter: function (value, row, index) {
						var rowStr = "";
						if (!!row.taskOrderTime)
							rowStr = '<span>' + row.taskOrderTime.substr(0, 10) + '</span>';
						return rowStr;
					}
				},
				{
					field : 'projectId', 
					title : '项目编号' 
				},
				{
					field : 'projectName', 
					title : '项目名称' 
				},
				{
					field : 'pmp',
					title : '项目经理'
				},
				{
					field : 'department',
					title : '所属处室'
				},
				{
					field : 'startTime', 
					title : '开始时间',
					formatter: function (value, row, index) {
						var rowStr = "";
						if (!!row.startTime)
							rowStr = '<span>' + row.startTime.substr(0, 10) + '</span>';
						return rowStr;
					}
				},
				{
					field : 'endTime', 
					title : '结束时间',
					formatter: function (value, row, index) {
						var rowStr = "";
						if (!!row.endTime)
							rowStr = '<span>' + row.endTime.substr(0, 10) + '</span>';
						return rowStr;
					}
				},
				{
					field : 'budgetCycle', 
					title : '预算周期' 
				},
				{
					field : 'budgetStatus',
					title : '预算下达情况' 
				},
				{
					field : 'projectStatus',
					title : '项目状态' 
				},
				{
					field : 'orderStatus',
					title : '订单下达状态' 
				},
				{
					field : 'projectType', 
					title : '项目类型' 
				},
				{
					field : 'remark', 
					title : '备注' 
				}]
            };
            $.table.init(options);
        });

		function projectBudgetInfo(){
			var row = $('#bootstrap-table').bootstrapTable('getSelections')[0];
			var url = ctx + "pm/projectInfo/budget/" + row.id;
			createMenuItem(url, "项目预算");
		}

		function projectProcurementResourceInfo(){
			var row = $('#bootstrap-table').bootstrapTable('getSelections')[0];
			var url = ctx + "pm/projectInfo/procurementResource/" + row.id;
			createMenuItem(url, "采购资源");
		}

		function projectCompanyProcurementInfo(){
			var row = $('#bootstrap-table').bootstrapTable('getSelections')[0];
			var url = ctx + "pm/projectInfo/companyProcurement/" + row.id;
			createMenuItem(url, "公司采购");
		}


		function toAddHtml(){
			$.operate.add($("input[name='projectId']").val());
		}

		// 导出项目信息Excel
		function exportExcel(){
			$.modal.loading("正在导出数据，请稍后...");
			var data = {};
			$.post(prefix + "/exportExcel", data, function(result) {
				if (result.code == web_status.SUCCESS) {
					window.location.href = ctx + "common/download?fileName=" + result.msg + "&delete=" + false;
				} else {
					$.modal.alertError(result.msg);
				}
				$.modal.closeLoading();
			});
		}

		$(function(){
			var time = new Date()
			var day = ('0' + time.getDate()).slice(-2)
			var month = ('0' + (time.getMonth() + 1)).slice(-2)
			var today = time.getFullYear() + '-' + month + '-' + day
			$('#cal-date').val(today)
		})
    </script>
</body>
</html>